#include <bits/stdc++.h>
#define int long long
using namespace std;
int t, n, m, now, l, V, cnt, ans, p[100005], L[100005], R[100005];
vector<pair<int, int>> k;
signed main()
{
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  freopen("detect.in", "r", stdin);
  freopen("detect.out", "w", stdout);
  cin >> t;
  while (t--)
  {
    cin >> n >> m >> l >> V, now = cnt = ans = 0, k.clear();
    for (int i = 1; i <= n; i++)
    {
      int d, v, a;
      cin >> d >> v >> a;
      if (a > 0)
      {
        R[i] = l;
        if (v > V)
        {
          L[i] = d;
          continue;
        }
        long double t = (V - v + 0.0000001) * 1.0 / a;
        L[i] = ceil(0.5 * a * t * t + v * t + d - 1e-14);
        if (L[i] > l)
          L[i] = R[i] = l + 1;
      }
      else if (a == 0)
      {
        if (v > V)
          L[i] = d, R[i] = l;
        else
          L[i] = R[i] = l + 1;
      }
      else
      {
        if (v <= V)
          L[i] = R[i] = l + 1;
        else
        {
          L[i] = d;
          long double t = (V - v + 0.0000001) * 1.0 / a;
          R[i] = floor(0.5 * a * t * t + v * t + d + 1e-14);
        }
      }
    }
    for (int i = 1; i <= m; i++)
      cin >> p[i];
    sort(p + 1, p + m + 1);
    for (int i = 1; i <= n; i++)
    {
      int l1 = lower_bound(p + 1, p + m + 1, L[i]) - p, r1 = upper_bound(p + 1, p + m + 1, R[i]) - p - 1;
      if (l1 <= r1)
        cnt++, k.push_back({r1, l1});
    }
    sort(k.begin(), k.end());
    for (auto i : k)
      if (i.second > now)
        ans++, now = i.first;
    cout << cnt << ' ' << m - ans << '\n';
  }
  exit(0);
}
